package com.sc.nft.admin.controller;

import com.sc.nft.admin.request.IdRequest;
import com.sc.nft.annotation.SysMemberLogin;
import com.sc.nft.entity.EcologyHatchExtraRewards;
import com.sc.nft.entity.dto.EcologyHatchExtraRewardsDTO;
import com.sc.nft.entity.dto.EcologyHatchExtraRewardsSaveDTO;
import com.sc.nft.entity.req.EcologyHatchExchangeConfRequest;
import com.sc.nft.entity.vo.AdminEcologyHatchExchangeConfVO;
import com.sc.nft.entity.vo.EcologyHatchExtraRewardsAdminVO;
import com.sc.nft.service.EcologyHatchExtraRewardsConfigService;
import com.sc.nft.service.EcologyHatchExtraRewardsService;
import com.sc.nft.service.EcologyHatchMethodCollectionConfService;
import com.sc.nft.sup.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @author 朱梦晨
 * @Description:
 * @date 2024-09-25
 */
@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/admin/ecologyHatch/extraRewards")
@Api("生态熔炼额外奖励")
public class EcologyHatchExtraRewardsController {


    private final EcologyHatchExtraRewardsService ecologyHatchExtraRewardsService;

    private final EcologyHatchExtraRewardsConfigService ecologyHatchExtraRewardsConfigService;

    private final EcologyHatchMethodCollectionConfService ecologyHatchMethodCollectionConfService;


    @PostMapping(value = "/edit", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "新增或者修改额外配置奖励", notes = "新增或者修改额外配置奖励", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result editEcologyHatchExchangeConf(@Valid @RequestBody EcologyHatchExtraRewardsSaveDTO dto) {
        ecologyHatchExtraRewardsService.editEcologyHatchExtraRewards(dto);
        return Result.success();
    }


    @PostMapping(value = "/detail", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "额外配置奖励详情", notes = "额外配置奖励详情", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result<EcologyHatchExtraRewardsAdminVO> getAdminEcologyHatchExchangeConf(@Valid @RequestBody EcologyHatchExtraRewardsDTO dto) {
        return Result.success(ecologyHatchExtraRewardsService.findEcologyHatchExtraRewards(dto));
    }


    @PostMapping(value = "/deleteConfig", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "删除配置奖励", notes = "删除配置奖励", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result dealExchangeUseProps(@Valid @RequestBody IdRequest request) {
        ecologyHatchExtraRewardsConfigService.deleteEcologyHatchExtraRewardsConfigById(request.getId());
        return Result.success();
    }


    @PostMapping(value = "/extraRewardsMethodScript", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "生成奖励配置方式 脚本", notes = "生成奖励配置方式 脚本", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result extraRewardsMethodScript() {
        ecologyHatchExtraRewardsService.extraRewardsMethodScript();
        return Result.success();
    }



    @PostMapping(value = "/updateHatchMethodCollectionConfIsMainByIdScript", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "修改熔炼方式藏品配置 主藏品脚本", notes = "修改熔炼方式藏品配置 主藏品脚本", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result updateHatchMethodCollectionConfIsMainByIdScript() {
        ecologyHatchMethodCollectionConfService.updateHatchMethodCollectionConfIsMainByIdScript();
        return Result.success();
    }


}
